<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>填坑录 | 前端攻城狮ZhuoRu</title><meta name="keywords" content="张卓如,web,前端"><meta name="author" content="ZhuoRu"><meta name="copyright" content="ZhuoRu"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="baidu-site-verification" content="code-0ABMo98myg"><meta name="description" content="2021年入职新公司,工作中的血泪填坑录">
<meta property="og:type" content="article">
<meta property="og:title" content="填坑录">
<meta property="og:url" content="https://zhangzhuoru.gitee.io/web/post/16106.html">
<meta property="og:site_name" content="前端攻城狮ZhuoRu">
<meta property="og:description" content="2021年入职新公司,工作中的血泪填坑录">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://zhangzhuoru.gitee.io/web/img/tab99.png">
<meta property="article:published_time" content="2022-11-26T16:31:04.787Z">
<meta property="article:modified_time" content="2022-10-05T14:43:18.285Z">
<meta property="article:author" content="ZhuoRu">
<meta property="article:tag" content="web">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zhangzhuoru.gitee.io/web/img/tab99.png"><link rel="shortcut icon" href="/web/img/favicon.png"><link rel="canonical" href="https://zhangzhuoru.gitee.io/web/post/16106"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/web/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/web/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":500},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: ZhuoRu","link":"链接: ","source":"来源: 前端攻城狮ZhuoRu","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-10-05 22:43:18'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><link rel="stylesheet" href="./css/custom.css"><link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/tzy13755126023/BLOG_SOURCE/css/function.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://fastly.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css"  media="defer" onload="this.media='all'"><svg aria-hidden="true" style="position:absolute; overflow:hidden; width:0; height:0"><symbol id="icon-sun" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol><symbol id="icon-moon" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol></svg><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box"><div class="pokeball-back"></div><div class="pokeball-loading"><div class="pokeball" id="pokeball-normal"></div><div class="pokeball" id="pokeball-great"></div><div class="pokeball" id="pokeball-ultra"></div><div class="pokeball" id="pokeball-master"></div><div class="pokeball" id="pokeball-safari"></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="https://thirdqq.qlogo.cn/g?b=sdk&amp;nk=2276839311&amp;s=140" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/web/archives/"><div class="headline">文章</div><div class="length-num">8</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/web/tags/"><div class="headline">标签</div><div class="length-num">9</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/web/categories/"><div class="headline">分类</div><div class="length-num">5</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/web/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/web/archives/"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span></a></div><div class="menus_item"><a class="site-page" href="/web/sponsorWall/"><i class="fa-fw fas fa-images"></i><span> 赞助墙</span></a></div><div class="menus_item"><a class="site-page" href="/web/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/web/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/web/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/web/other/"><i class="fa-fw fas fa-coffee"></i><span> Demo</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/web/img/tab99.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/web/">前端攻城狮ZhuoRu</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/web/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/web/archives/"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span></a></div><div class="menus_item"><a class="site-page" href="/web/sponsorWall/"><i class="fa-fw fas fa-images"></i><span> 赞助墙</span></a></div><div class="menus_item"><a class="site-page" href="/web/comment/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/web/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/web/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/web/other/"><i class="fa-fw fas fa-coffee"></i><span> Demo</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">填坑录</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-11-26T16:31:04.787Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-10-05T14:43:18.285Z" title="更新于 2022-10-05 22:43:18">2022-10-05</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/web/categories/%E8%AF%B4%E6%98%8E%E4%B9%A6/">说明书</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>25分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="填坑录"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="可园填坑回忆录"><a href="#可园填坑回忆录" class="headerlink" title="可园填坑回忆录"></a>可园填坑回忆录</h1><h2 id="vue中点击不可用-一般都是自带了if限制条件"><a href="#vue中点击不可用-一般都是自带了if限制条件" class="headerlink" title="vue中点击不可用,一般都是自带了if限制条件"></a>vue中点击不可用,一般都是自带了if限制条件</h2><h2 id="请求发出去了-后台收不到-可能是请求头格式错误"><a href="#请求发出去了-后台收不到-可能是请求头格式错误" class="headerlink" title="请求发出去了,后台收不到,可能是请求头格式错误"></a>请求发出去了,后台收不到,可能是请求头格式错误</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//支持formData其他提交形式</span></span><br><span class="line">service.<span class="property">defaults</span>.<span class="property">transformRequest</span> = [<span class="keyword">function</span> (<span class="params">data, headers</span>) &#123;</span><br><span class="line">  <span class="keyword">if</span> (headers[<span class="string">&#x27;Content-Type&#x27;</span>] === <span class="string">&#x27;application/json&#x27;</span>) &#123;</span><br><span class="line">    <span class="comment">// 把一个参数对象格式化为一个字符串</span></span><br><span class="line">    <span class="keyword">return</span> <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(data)</span><br><span class="line">  &#125; <span class="keyword">else</span> <span class="keyword">if</span> (headers[<span class="string">&#x27;Content-Type&#x27;</span>] === <span class="string">&#x27;multipart/form-data;charset=UTF-8&#x27;</span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> data</span><br><span class="line">  &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">    <span class="comment">/* headers[&#x27;Content-Type&#x27;] = &#x27;application/json&#x27; */</span></span><br><span class="line">    headers[<span class="string">&#x27;Content-Type&#x27;</span>] = <span class="string">&#x27;application/x-www-form-urlencoded&#x27;</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">return</span> qs.<span class="title function_">stringify</span>(data)</span><br><span class="line"></span><br><span class="line">&#125;]</span><br></pre></td></tr></table></figure>
<h2 id="当前页面查不到元素-可以去全局搜索-查找所有文件"><a href="#当前页面查不到元素-可以去全局搜索-查找所有文件" class="headerlink" title="当前页面查不到元素,可以去全局搜索,查找所有文件"></a>当前页面查不到元素,可以去全局搜索,查找所有文件</h2><h2 id="图片下载有两种-一种是文件流-没试过-最多的就是路径拼接"><a href="#图片下载有两种-一种是文件流-没试过-最多的就是路径拼接" class="headerlink" title="图片下载有两种,一种是文件流,没试过,最多的就是路径拼接,"></a>图片下载有两种,一种是文件流,没试过,最多的就是路径拼接,</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//获取文件流 通过url+id</span></span><br><span class="line"><span class="title class_">TableDemoDownLoadByUrlID</span>: <span class="keyword">function</span> (<span class="params">urlString</span>) &#123;</span><br><span class="line">  <span class="keyword">return</span> <span class="variable language_">window</span>.<span class="property">location</span>.<span class="property">href</span> = <span class="string">`<span class="subst">$&#123;baseIP&#125;</span><span class="subst">$&#123;urlString&#125;</span>&amp;token=<span class="subst">$&#123;getToken()&#125;</span>`</span>;</span><br><span class="line">&#125;,</span><br><span class="line"><span class="comment">//获取url直接下载</span></span><br><span class="line"><span class="attr">completeImageUrl</span>: <span class="keyword">function</span> (<span class="params">urlString</span>) &#123;</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;urlString&#x27;</span>,urlString)</span><br><span class="line">  <span class="keyword">var</span> path = urlString.<span class="title function_">replace</span>(<span class="string">&quot;getFileStream&quot;</span>, <span class="string">&quot;getAnyFileStream&quot;</span>);</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(path);</span><br><span class="line">  <span class="keyword">return</span> <span class="variable language_">window</span>.<span class="property">location</span>.<span class="property">href</span> = <span class="string">`<span class="subst">$&#123;path&#125;</span>?token=<span class="subst">$&#123;getToken()&#125;</span>`</span>;</span><br><span class="line">&#125;,</span><br></pre></td></tr></table></figure>
<h2 id="上传的图片无法保存进数据库-一是上传不能传参-二是未回显请求回的数据"><a href="#上传的图片无法保存进数据库-一是上传不能传参-二是未回显请求回的数据" class="headerlink" title="上传的图片无法保存进数据库,一是上传不能传参,二是未回显请求回的数据"></a>上传的图片无法保存进数据库,一是上传不能传参,二是未回显请求回的数据</h2><h2 id="el-date-picker-无法修改时间"><a href="#el-date-picker-无法修改时间" class="headerlink" title="el-date-picker 无法修改时间"></a>el-date-picker 无法修改时间</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&lt;el-date-picker</span><br><span class="line">   v-model=&quot;form.approvalDate&quot;</span><br><span class="line">   style=&quot;width: 100%&quot;</span><br><span class="line">   format=&quot;yyyy-MM-dd&quot;</span><br><span class="line">   value-format=&quot;yyyy-MM-dd&quot;</span><br><span class="line">   type=&quot;date&quot;</span><br><span class="line">   placeholder=&quot;选择日期&quot;</span><br><span class="line">&gt;&lt;/el-date-picker&gt;</span><br><span class="line">如果form.approvalDate的数据的格式是loanTermTime: &quot;2021-11-16 00:00:00&quot;,数据无法修改,去掉限制即可</span><br><span class="line">&lt;el-date-picker</span><br><span class="line">   v-model=&quot;form.approvalDate&quot;</span><br><span class="line">   style=&quot;width: 100%&quot;</span><br><span class="line">   type=&quot;date&quot;</span><br><span class="line">   placeholder=&quot;选择日期&quot;</span><br><span class="line">&gt;&lt;/el-date-picker&gt;</span><br><span class="line"></span><br><span class="line">value-format=&quot;yyyy-MM-dd&quot;的作用是限制v-model的值,可手动修为所需时间格式,日期格式化上传数据,下附使用方法</span><br><span class="line"></span><br><span class="line">import &#123; parseTime &#125; from &#x27;@/utils/index.js&#x27;</span><br><span class="line">parseTime(formData.loanTime,&#x27;&#123;y&#125;-&#123;m&#125;-&#123;d&#125;&#x27;);</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 日期格式化</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">parseTime</span>(<span class="params">time, pattern</span>) &#123;</span><br><span class="line">    <span class="keyword">if</span> (<span class="variable language_">arguments</span>.<span class="property">length</span> === <span class="number">0</span> || !time) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">const</span> format = pattern || <span class="string">&quot;&#123;y&#125;-&#123;m&#125;-&#123;d&#125; &#123;h&#125;:&#123;i&#125;:&#123;s&#125;&quot;</span>;</span><br><span class="line">    <span class="keyword">let</span> date;</span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">typeof</span> time === <span class="string">&quot;object&quot;</span>) &#123;</span><br><span class="line">        date = time;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">typeof</span> time === <span class="string">&quot;string&quot;</span> &amp;&amp; <span class="regexp">/^[0-9]+$/</span>.<span class="title function_">test</span>(time)) &#123;</span><br><span class="line">            time = <span class="built_in">parseInt</span>(time);</span><br><span class="line">        &#125; <span class="keyword">else</span> <span class="keyword">if</span> (<span class="keyword">typeof</span> time === <span class="string">&quot;string&quot;</span>) &#123;</span><br><span class="line">            time = time.<span class="title function_">replace</span>(<span class="keyword">new</span> <span class="title class_">RegExp</span>(<span class="regexp">/-/gm</span>), <span class="string">&quot;/&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">typeof</span> time === <span class="string">&quot;number&quot;</span> &amp;&amp; time.<span class="title function_">toString</span>().<span class="property">length</span> === <span class="number">10</span>) &#123;</span><br><span class="line">            time = time * <span class="number">1000</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        date = <span class="keyword">new</span> <span class="title class_">Date</span>(time);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">const</span> formatObj = &#123;</span><br><span class="line">        <span class="attr">y</span>: date.<span class="title function_">getFullYear</span>(),</span><br><span class="line">        <span class="attr">m</span>: date.<span class="title function_">getMonth</span>() + <span class="number">1</span>,</span><br><span class="line">        <span class="attr">d</span>: date.<span class="title function_">getDate</span>(),</span><br><span class="line">        <span class="attr">h</span>: date.<span class="title function_">getHours</span>(),</span><br><span class="line">        <span class="attr">i</span>: date.<span class="title function_">getMinutes</span>(),</span><br><span class="line">        <span class="attr">s</span>: date.<span class="title function_">getSeconds</span>(),</span><br><span class="line">        <span class="attr">a</span>: date.<span class="title function_">getDay</span>()</span><br><span class="line">    &#125;;</span><br><span class="line">    <span class="keyword">const</span> time_str = format.<span class="title function_">replace</span>(<span class="regexp">/&#123;(y|m|d|h|i|s|a)+&#125;/g</span>, <span class="function">(<span class="params">result, key</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">let</span> value = formatObj[key];</span><br><span class="line">        <span class="comment">// Note: getDay() returns 0 on Sunday</span></span><br><span class="line">        <span class="keyword">if</span> (key === <span class="string">&quot;a&quot;</span>) &#123;</span><br><span class="line">            <span class="keyword">return</span> [<span class="string">&quot;日&quot;</span>, <span class="string">&quot;一&quot;</span>, <span class="string">&quot;二&quot;</span>, <span class="string">&quot;三&quot;</span>, <span class="string">&quot;四&quot;</span>, <span class="string">&quot;五&quot;</span>, <span class="string">&quot;六&quot;</span>][value];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (result.<span class="property">length</span> &gt; <span class="number">0</span> &amp;&amp; value &lt; <span class="number">10</span>) &#123;</span><br><span class="line">            value = <span class="string">&quot;0&quot;</span> + value;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> value || <span class="number">0</span>;</span><br><span class="line">    &#125;);</span><br><span class="line">    <span class="keyword">return</span> time_str;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="上传身份证-父子组件数据无法同步-异步时"><a href="#上传身份证-父子组件数据无法同步-异步时" class="headerlink" title="上传身份证 父子组件数据无法同步,异步时"></a>上传身份证 父子组件数据无法同步,异步时</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&lt;UploadFile</span><br><span class="line">   v-if=&quot;isFilesListData&quot;</span><br><span class="line">   @changeFilesIDs=&quot;getFilesIDs&quot;</span><br><span class="line">   :sendFilesIDsDatas=&quot;filesList&quot;</span><br><span class="line">   :sentImages=&quot;true&quot;</span><br><span class="line">   :idImages=&quot;false&quot;</span><br><span class="line">   :limit-file-types=&quot;[&#x27;image/png&#x27;, &#x27;image/jpeg&#x27;]&quot;</span><br><span class="line">&gt;</span><br><span class="line">    &lt;template v-slot:button-content&gt;上传图片&lt;/template&gt;</span><br><span class="line">    &lt;template v-slot:tip&gt;请选择图片上传&lt;/template&gt;</span><br><span class="line">&lt;/UploadFile&gt;</span><br><span class="line">//在父组件中使用v-if,</span><br><span class="line">//一开始时,默认v-if为false,请求完后修改为true</span><br><span class="line">//isFilesListData:false,</span><br><span class="line">//this.isFilesListData=true;</span><br></pre></td></tr></table></figure>
<h2 id="当后端需要参数要定制"><a href="#当后端需要参数要定制" class="headerlink" title="当后端需要参数要定制"></a>当后端需要参数要定制</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//判断rule3items对象是否存在id</span></span><br><span class="line"><span class="keyword">if</span> (<span class="title class_">Reflect</span>.<span class="title function_">has</span>(rule3items, <span class="string">&#x27;id&#x27;</span>)) &#123;</span><br><span class="line">	<span class="title class_">Reflect</span>.<span class="title function_">deleteProperty</span>(rule3items, <span class="string">&#x27;id&#x27;</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 浅拷贝, 将origin属性对应的值转移到target</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> target 目标</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> origin 原</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> <span class="variable">defaultVal</span></span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> props 需要copy的属性</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="title function_">copyProperties</span>(<span class="params">target, origin, ...props</span>) &#123;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">const</span> prop <span class="keyword">of</span> props) &#123;</span><br><span class="line"> 	target[prop] = origin[prop]</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> fieldList = <span class="title class_">Object</span>.<span class="title function_">keys</span>(<span class="variable language_">this</span>.<span class="property">form</span>);</span><br><span class="line"><span class="variable language_">this</span>.<span class="property">PMethods</span>.<span class="title function_">copyProperties</span>(<span class="variable language_">this</span>.<span class="property">form</span>, val, ...fieldList);</span><br></pre></td></tr></table></figure>
<h2 id="数组转字符串"><a href="#数组转字符串" class="headerlink" title="数组转字符串"></a>数组转字符串</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> idString = <span class="variable language_">this</span>.<span class="property">PMethods</span>.<span class="title class_">ArrayToString</span>(<span class="variable language_">this</span>.<span class="property">tableRowIds</span>);</span><br><span class="line"><span class="title class_">ArrayToString</span>: <span class="keyword">function</span> (<span class="params">arr</span>) &#123;</span><br><span class="line">    <span class="keyword">if</span> (!<span class="title class_">Array</span>.<span class="title function_">isArray</span>(arr) || arr.<span class="property">length</span> &lt; <span class="number">1</span>) <span class="keyword">return</span> <span class="string">&quot;&quot;</span></span><br><span class="line">    <span class="keyword">return</span> <span class="string">&#x27;[&quot;&#x27;</span> + arr.<span class="title function_">join</span>(<span class="string">&#x27;&quot;,&quot;&#x27;</span>) + <span class="string">&#x27;&quot;]&#x27;</span></span><br><span class="line">&#125;,</span><br></pre></td></tr></table></figure>
<h1 id="Object-keys-可浅拷贝"><a href="#Object-keys-可浅拷贝" class="headerlink" title="Object.keys 可浅拷贝"></a>Object.keys 可浅拷贝</h1><p><code>Object.keys()</code> 方法会返回一个由一个给定对象的自身可枚举属性组成的数组，数组中属性名的排列顺序和正常循环遍历该对象时返回的顺序一致 。</p>
<h2 id="语法"><a href="#语法" class="headerlink" title="语法"></a><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#syntax">语法</a></h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Object.keys(obj)</span><br></pre></td></tr></table></figure>
<h3 id="参数"><a href="#参数" class="headerlink" title="参数"></a><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#parameters">参数</a></h3><ul>
<li><p>obj</p>
<p>要返回其枚举自身属性的对象。</p>
</li>
</ul>
<h3 id="返回值"><a href="#返回值" class="headerlink" title="返回值"></a><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#返回值">返回值</a></h3><p>一个表示给定对象的所有可枚举属性的字符串数组。</p>
<h2 id="描述"><a href="#描述" class="headerlink" title="描述"></a><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#description">描述</a></h2><p><code>Object.keys</code> 返回一个所有元素为字符串的数组，其元素来自于从给定的<code>object</code>上面可直接枚举的属性。这些属性的顺序与手动遍历该对象属性时的一致。</p>
<p><img src= "/web/img/loading.gif" data-lazy-src="C:\Users\sushengren\AppData\Roaming\Typora\typora-user-images\image-20220519114637840.png" alt=""></p>
<h2 id="例子"><a href="#例子" class="headerlink" title="例子"></a><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#例子">例子</a></h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// simple array</span></span><br><span class="line"><span class="keyword">var</span> arr = [<span class="string">&#x27;a&#x27;</span>, <span class="string">&#x27;b&#x27;</span>, <span class="string">&#x27;c&#x27;</span>];</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(arr)); <span class="comment">// console: [&#x27;0&#x27;, &#x27;1&#x27;, &#x27;2&#x27;]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// array like object</span></span><br><span class="line"><span class="keyword">var</span> obj = &#123; <span class="number">0</span>: <span class="string">&#x27;a&#x27;</span>, <span class="number">1</span>: <span class="string">&#x27;b&#x27;</span>, <span class="number">2</span>: <span class="string">&#x27;c&#x27;</span> &#125;;</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(obj)); <span class="comment">// console: [&#x27;0&#x27;, &#x27;1&#x27;, &#x27;2&#x27;]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// array like object with random key ordering</span></span><br><span class="line"><span class="keyword">var</span> anObj = &#123; <span class="number">100</span>: <span class="string">&#x27;a&#x27;</span>, <span class="number">2</span>: <span class="string">&#x27;b&#x27;</span>, <span class="number">7</span>: <span class="string">&#x27;c&#x27;</span> &#125;;</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(anObj)); <span class="comment">// console: [&#x27;2&#x27;, &#x27;7&#x27;, &#x27;100&#x27;]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// getFoo is a property which isn&#x27;t enumerable</span></span><br><span class="line"><span class="keyword">var</span> myObj = <span class="title class_">Object</span>.<span class="title function_">create</span>(&#123;&#125;, &#123;</span><br><span class="line">  <span class="attr">getFoo</span>: &#123;</span><br><span class="line">    <span class="attr">value</span>: <span class="keyword">function</span> (<span class="params"></span>) &#123; <span class="keyword">return</span> <span class="variable language_">this</span>.<span class="property">foo</span>; &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;);</span><br><span class="line">myObj.<span class="property">foo</span> = <span class="number">1</span>;</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(myObj)); <span class="comment">// console: [&#x27;foo&#x27;]</span></span><br></pre></td></tr></table></figure>
<h2 id="配合浅拷贝"><a href="#配合浅拷贝" class="headerlink" title="配合浅拷贝"></a>配合浅拷贝</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 浅拷贝, 将origin属性对应的值转移到target</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> target 目标</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> origin 原</span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> <span class="variable">defaultVal</span></span></span><br><span class="line"><span class="comment">* <span class="doctag">@param</span> props 需要copy的属性</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="title function_">copyProperties</span>(<span class="params">target, origin, ...props</span>) &#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">const</span> prop <span class="keyword">of</span> props) &#123;</span><br><span class="line">        target[prop] = origin[prop]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> origin = &#123; <span class="attr">a</span>: <span class="string">&#x27;a&#x27;</span>, <span class="attr">b</span>: <span class="string">&#x27;b&#x27;</span>, <span class="attr">c</span>: <span class="string">&#x27;c&#x27;</span> &#125;;</span><br><span class="line"><span class="keyword">var</span> target = &#123; <span class="attr">a</span>: <span class="string">&#x27;&#x27;</span>, <span class="attr">b</span>: <span class="string">&#x27;&#x27;</span> &#125;</span><br><span class="line"><span class="keyword">let</span> props = <span class="title class_">Object</span>.<span class="title function_">keys</span>(target)</span><br><span class="line"><span class="comment">//可以快速</span></span><br><span class="line"><span class="title function_">copyProperties</span>(target, origin, ...props)</span><br></pre></td></tr></table></figure>
<h1 id="数组常见使用"><a href="#数组常见使用" class="headerlink" title="数组常见使用"></a>数组常见使用</h1><h2 id="find-返回符合条件的第一个元素"><a href="#find-返回符合条件的第一个元素" class="headerlink" title="find 返回符合条件的第一个元素"></a><code>find</code> 返回符合条件的第一个元素</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> array1 = [<span class="number">5</span>, <span class="number">12</span>, <span class="number">8</span>, <span class="number">130</span>, <span class="number">44</span>];</span><br><span class="line"><span class="comment">//返回符合条件的元素</span></span><br><span class="line"><span class="keyword">const</span> found = array1.<span class="title function_">find</span>(<span class="function"><span class="params">element</span> =&gt;</span> element &gt; <span class="number">10</span>);</span><br></pre></td></tr></table></figure>
<h2 id="findIndex-返回符合条件的下标"><a href="#findIndex-返回符合条件的下标" class="headerlink" title="findIndex() 返回符合条件的下标"></a><code>findIndex()</code> 返回符合条件的下标</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> array1 = [<span class="number">5</span>, <span class="number">12</span>, <span class="number">8</span>, <span class="number">130</span>, <span class="number">44</span>];</span><br><span class="line"><span class="comment">//返回符合条件的下标</span></span><br><span class="line"><span class="keyword">const</span> isLargeNumber = array1.<span class="title function_">findIndex</span>(<span class="function">(<span class="params">element</span>) =&gt;</span> element &gt; <span class="number">13</span>);</span><br></pre></td></tr></table></figure>
<h2 id="filter-过滤-返回符合条件的新数组。"><a href="#filter-过滤-返回符合条件的新数组。" class="headerlink" title="filter() 过滤, 返回符合条件的新数组。"></a><code>filter()</code> 过滤, 返回符合条件的新数组。</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> words = [<span class="string">&#x27;spray&#x27;</span>, <span class="string">&#x27;limit&#x27;</span>, <span class="string">&#x27;elite&#x27;</span>, <span class="string">&#x27;exuberant&#x27;</span>, <span class="string">&#x27;destruction&#x27;</span>, <span class="string">&#x27;present&#x27;</span>];</span><br><span class="line">创建一个新数组, 返回符合条件的所有元素。</span><br><span class="line"><span class="keyword">const</span> result = words.<span class="title function_">filter</span>(<span class="function"><span class="params">word</span> =&gt;</span> word.<span class="property">length</span> &gt; <span class="number">6</span>);</span><br><span class="line"></span><br><span class="line">利用 filter 去除数组空值：</span><br><span class="line"><span class="keyword">let</span>  newrr = [<span class="string">&#x27;&#x27;</span>,<span class="string">&#x27;&#x27;</span>,<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>]</span><br><span class="line"><span class="keyword">var</span> newArr = newrr.<span class="title function_">filter</span>(<span class="function"><span class="params">item</span> =&gt;</span> item)</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(newArr)</span><br><span class="line"><span class="comment">//[1,2,3]</span></span><br></pre></td></tr></table></figure>
<h2 id="join-返回拼接字符串"><a href="#join-返回拼接字符串" class="headerlink" title="join() 返回拼接字符串"></a><code>join()</code> 返回拼接字符串</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> elements = [<span class="string">&#x27;Fire&#x27;</span>, <span class="string">&#x27;Air&#x27;</span>,<span class="string">&#x27;&#x27;</span>, <span class="string">&#x27;Water&#x27;</span>];</span><br><span class="line"><span class="comment">//默认逗号拼接</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(elements.<span class="title function_">join</span>());</span><br><span class="line"><span class="comment">// expected output: &quot;Fire,Air,,Water&quot;</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(elements.<span class="title function_">join</span>(<span class="string">&#x27;&#x27;</span>));</span><br><span class="line"><span class="comment">// expected output: &quot;FireAirWater&quot;</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(elements.<span class="title function_">join</span>(<span class="string">&#x27;-&#x27;</span>));</span><br><span class="line"><span class="comment">// expected output: &quot;Fire-Air--Water&quot;</span></span><br></pre></td></tr></table></figure>
<h2 id="reduce-累加"><a href="#reduce-累加" class="headerlink" title="reduce  累加"></a><code>reduce</code>  累加</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> array1 = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];</span><br><span class="line"><span class="keyword">const</span> reducer = array1.<span class="title function_">reduce</span>(<span class="function">(<span class="params">previousValue, currentValue</span>) =&gt;</span> previousValue + currentValue);</span><br><span class="line"><span class="comment">// expected output: reducer = 10</span></span><br></pre></td></tr></table></figure>
<h2 id="splice-可删除-替换或添加新的元素来修改数组-会改变原数组"><a href="#splice-可删除-替换或添加新的元素来修改数组-会改变原数组" class="headerlink" title="splice()  可删除,替换或添加新的元素来修改数组,会改变原数组"></a><code>splice()</code>  可删除,替换或添加新的元素来修改数组,会改变原数组</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> months = [<span class="string">&#x27;Jan&#x27;</span>, <span class="string">&#x27;March&#x27;</span>, <span class="string">&#x27;April&#x27;</span>, <span class="string">&#x27;June&#x27;</span>];</span><br><span class="line"><span class="comment">//第一位参数开始下标</span></span><br><span class="line"><span class="comment">//第二位参数大于零,替换;0,插入</span></span><br><span class="line"><span class="comment">//第三位参数替换;插入;添加的元素,不加删除</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//插入</span></span><br><span class="line">months.<span class="title function_">splice</span>(<span class="number">1</span>, <span class="number">0</span>, <span class="string">&#x27;Feb&#x27;</span>);</span><br><span class="line"><span class="comment">// expected output: Array [&quot;Jan&quot;, &quot;Feb&quot;, &quot;March&quot;, &quot;April&quot;, &quot;June&quot;]</span></span><br><span class="line"><span class="comment">//替换</span></span><br><span class="line">months.<span class="title function_">splice</span>(<span class="number">4</span>, <span class="number">1</span>, <span class="string">&#x27;May&#x27;</span>);</span><br><span class="line"><span class="comment">// expected output: Array [&quot;Jan&quot;, &quot;Feb&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;]</span></span><br><span class="line"><span class="comment">//添加</span></span><br><span class="line">months.<span class="title function_">splice</span>(<span class="number">4</span>, <span class="number">0</span>, <span class="string">&#x27;June&#x27;</span>);</span><br><span class="line"><span class="comment">// expected output: Array [&quot;Jan&quot;, &quot;Feb&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;]</span></span><br><span class="line"><span class="comment">//删除</span></span><br><span class="line">months.<span class="title function_">splice</span>(<span class="number">5</span>, <span class="number">1</span>);</span><br><span class="line"><span class="comment">// expected output: Array [&quot;Jan&quot;, &quot;Feb&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;]</span></span><br></pre></td></tr></table></figure>
<h2 id="forEach-或map方法对数组的每个元素执行一次给定的函数。循环"><a href="#forEach-或map方法对数组的每个元素执行一次给定的函数。循环" class="headerlink" title="forEach() 或map方法对数组的每个元素执行一次给定的函数。循环"></a><code>forEach()</code> 或<code>map</code>方法对数组的每个元素执行一次给定的函数。循环</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> array1 = [<span class="string">&#x27;a&#x27;</span>, <span class="string">&#x27;b&#x27;</span>, <span class="string">&#x27;c&#x27;</span>];</span><br><span class="line"><span class="comment">//arr.forEach(items , index , array)</span></span><br><span class="line">array1.<span class="title function_">forEach</span>(<span class="function"><span class="params">element</span> =&gt;</span> <span class="variable language_">console</span>.<span class="title function_">log</span>(element));</span><br></pre></td></tr></table></figure>
<h2 id="reverse-位置颠倒，该方法会改变原数组。"><a href="#reverse-位置颠倒，该方法会改变原数组。" class="headerlink" title="reverse() 位置颠倒，该方法会改变原数组。"></a><code>reverse()</code> 位置颠倒，该方法会改变原数组。</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> array1 = [<span class="string">&#x27;one&#x27;</span>, <span class="string">&#x27;two&#x27;</span>, <span class="string">&#x27;three&#x27;</span>];</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;array1:&#x27;</span>, array1);</span><br><span class="line"><span class="comment">// expected output: &quot;array1:&quot; Array [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;]</span></span><br><span class="line"><span class="keyword">const</span> reversed = array1.<span class="title function_">reverse</span>();</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;reversed:&#x27;</span>, reversed);</span><br><span class="line"><span class="comment">// expected output: &quot;reversed:&quot; Array [&quot;three&quot;, &quot;two&quot;, &quot;one&quot;]</span></span><br></pre></td></tr></table></figure>
<h2 id="sort-排序，默认排序顺序是在将元素转换为字符串，然后比较它们的UTF-16代码单元值序列时构建的"><a href="#sort-排序，默认排序顺序是在将元素转换为字符串，然后比较它们的UTF-16代码单元值序列时构建的" class="headerlink" title="sort() 排序，默认排序顺序是在将元素转换为字符串，然后比较它们的UTF-16代码单元值序列时构建的"></a><code>sort()</code> 排序，默认排序顺序是在将元素转换为字符串，然后比较它们的UTF-16代码单元值序列时构建的</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> numbers = [<span class="number">4</span>, <span class="number">2</span>, <span class="number">5</span>, <span class="number">1</span>, <span class="number">3</span>];</span><br><span class="line">numbers.<span class="title function_">sort</span>(<span class="function">(<span class="params">a, b</span>) =&gt;</span> a - b);</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(numbers);</span><br><span class="line"><span class="comment">// [1, 2, 3, 4, 5]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//对象可以按照某个属性排序：</span></span><br><span class="line"><span class="keyword">var</span> items = [</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;Edward&#x27;</span>, <span class="attr">value</span>: <span class="number">21</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;Sharpe&#x27;</span>, <span class="attr">value</span>: <span class="number">37</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;And&#x27;</span>, <span class="attr">value</span>: <span class="number">45</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;The&#x27;</span>, <span class="attr">value</span>: -<span class="number">12</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;Magnetic&#x27;</span> &#125;,</span><br><span class="line">  &#123; <span class="attr">name</span>: <span class="string">&#x27;Zeros&#x27;</span>, <span class="attr">value</span>: <span class="number">37</span> &#125;</span><br><span class="line">];</span><br><span class="line"></span><br><span class="line"><span class="comment">// sort by value</span></span><br><span class="line">items.<span class="title function_">sort</span>(<span class="keyword">function</span> (<span class="params">a, b</span>) &#123;</span><br><span class="line">  <span class="keyword">return</span> (a.<span class="property">value</span> - b.<span class="property">value</span>)</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h1 id="互助可取之处"><a href="#互助可取之处" class="headerlink" title="互助可取之处"></a>互助可取之处</h1><h2 id="项目中要求可以拖拽element-UI-table-的表格"><a href="#项目中要求可以拖拽element-UI-table-的表格" class="headerlink" title="项目中要求可以拖拽element UI table 的表格"></a>项目中要求可以拖拽element UI table 的表格</h2><h3 id="使用-sortablejs-插件"><a href="#使用-sortablejs-插件" class="headerlink" title="使用 sortablejs 插件"></a>使用 sortablejs 插件</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install sortablejs --save</span><br></pre></td></tr></table></figure>
<h3 id="引入"><a href="#引入" class="headerlink" title="引入"></a>引入</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="title class_">Sortable</span> <span class="keyword">from</span> <span class="string">&quot;sortablejs&quot;</span>;</span><br></pre></td></tr></table></figure>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div class=&quot;table&quot;&gt;</span><br><span class="line">    &lt;el-table</span><br><span class="line">      ref=&quot;dragTable&quot;</span><br><span class="line">      :data=&quot;tableData&quot;</span><br><span class="line">      border</span><br><span class="line">      :row-class-name=&quot;tableRowClassName&quot;</span><br><span class="line">    &gt;</span><br><span class="line">      &lt;el-table-column prop=&quot;date&quot; label=&quot;日期&quot;&gt;&lt;/el-table-column&gt;</span><br><span class="line">      &lt;el-table-column prop=&quot;name&quot; label=&quot;姓名&quot;&gt;&lt;/el-table-column&gt;</span><br><span class="line">      &lt;el-table-column prop=&quot;address&quot; label=&quot;地址&quot;&gt;&lt;/el-table-column&gt;</span><br><span class="line">      &lt;el-table-column label=&quot;操作&quot;&gt;</span><br><span class="line">        &lt;template&gt;</span><br><span class="line">          &lt;el-button class=&quot;move&quot; type=&quot;text&quot; size=&quot;small&quot;&gt;拖 拽&lt;/el-button&gt;</span><br><span class="line">        &lt;/template&gt;</span><br><span class="line">      &lt;/el-table-column&gt;</span><br><span class="line">    &lt;/el-table&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line">&lt;script&gt;</span><br><span class="line">import Sortable from &quot;sortablejs&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  data() &#123;</span><br><span class="line">    return &#123;</span><br><span class="line">      tableData: [</span><br><span class="line">        &#123;</span><br><span class="line">          id: &quot;1&quot;,</span><br><span class="line">          name: &quot;text_1&quot;,</span><br><span class="line">          date: &quot;1111-11-11&quot;,</span><br><span class="line">          address: &quot;测试_1&quot;,</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">          id: &quot;2&quot;,</span><br><span class="line">          name: &quot;text_2_不可拖拽&quot;,</span><br><span class="line">          date: &quot;2222-22-22&quot;,</span><br><span class="line">          address: &quot;测试_2_不可拖拽&quot;,</span><br><span class="line">          disabled: true,</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">          id: &quot;3&quot;,</span><br><span class="line">          name: &quot;text_3&quot;,</span><br><span class="line">          date: &quot;3333-33-33&quot;,</span><br><span class="line">          address: &quot;测试_3&quot;,</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">          id: &quot;4&quot;,</span><br><span class="line">          name: &quot;text_4&quot;,</span><br><span class="line">          date: &quot;4444-44-44&quot;,</span><br><span class="line">          address: &quot;测试_4&quot;,</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">          id: &quot;5&quot;,</span><br><span class="line">          name: &quot;text_5&quot;,</span><br><span class="line">          date: &quot;5555-55-55&quot;,</span><br><span class="line">          address: &quot;测试_5&quot;,</span><br><span class="line">        &#125;,</span><br><span class="line">      ],</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">  methods: &#123;</span><br><span class="line">    // 创建sortable实例</span><br><span class="line">    initSortable() &#123;</span><br><span class="line">      // 获取表格row的父节点</span><br><span class="line">      const ele = this.$refs.dragTable.$el.querySelector(</span><br><span class="line">        &quot;.el-table__body &gt; tbody&quot;</span><br><span class="line">      );</span><br><span class="line">      // 创建拖拽实例</span><br><span class="line">      let dragTable = Sortable.create(ele, &#123;</span><br><span class="line">        animation: 150, //动画</span><br><span class="line">        disabled: false, // 拖拽不可用? false 启用（刚刚渲染表格的时候起作用，后面不起作用）</span><br><span class="line">        handle: &quot;.move&quot;, //指定拖拽目标，点击此目标才可拖拽元素(此例中设置操作按钮拖拽)</span><br><span class="line">        filter: &quot;.disabled&quot;, //指定不可拖动的类名（el-table中可通过row-class-name设置行的class）</span><br><span class="line">        dragClass: &quot;dragClass&quot;, //设置拖拽样式类名</span><br><span class="line">        ghostClass: &quot;ghostClass&quot;, //设置拖拽停靠样式类名</span><br><span class="line">        chosenClass: &quot;chosenClass&quot;, //设置选中样式类名</span><br><span class="line">        // 开始拖动事件</span><br><span class="line">        onStart: () =&gt; &#123;</span><br><span class="line">          console.log(&quot;开始拖动&quot;);</span><br><span class="line">        &#125;,</span><br><span class="line">        // 结束拖动事件</span><br><span class="line">        onEnd: (&#123; newIndex, oldIndex &#125;) =&gt; &#123;</span><br><span class="line">          console.log(</span><br><span class="line">            &quot;结束拖动&quot;,</span><br><span class="line">            `拖动前索引$&#123;oldIndex&#125;---拖动后索引$&#123;newIndex&#125;`</span><br><span class="line">          );</span><br><span class="line">            const currRow = _this.tableData.splice(oldIndex, 1)[0];</span><br><span class="line">          this.tableData.splice(newIndex, 0, currRow);</span><br><span class="line">        &#125;,</span><br><span class="line">      &#125;);</span><br><span class="line">    &#125;,</span><br><span class="line">    // 设置表格row的class</span><br><span class="line">    tableRowClassName(&#123; row &#125;) &#123;</span><br><span class="line">      if (row.disabled) &#123;</span><br><span class="line">        return &quot;disabled&quot;;</span><br><span class="line">      &#125;</span><br><span class="line">      return &quot;&quot;;</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">  mounted() &#123;</span><br><span class="line">    this.initSortable();</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line">//注意如果加上scoped 样式就可能不起作用</span><br><span class="line">&lt;style lang=&#x27;scss&#x27;&gt;</span><br><span class="line">// 拖拽</span><br><span class="line">.dragClass &#123;</span><br><span class="line">  background: rgba($color: #41c21a, $alpha: 0.5) !important;</span><br><span class="line">&#125;</span><br><span class="line">// 停靠</span><br><span class="line">.ghostClass &#123;</span><br><span class="line">  background: rgba($color: #6cacf5, $alpha: 0.5) !important;</span><br><span class="line">&#125;</span><br><span class="line">// 选择</span><br><span class="line">.chosenClass:hover &gt; td &#123;</span><br><span class="line">  background: rgba($color: #f56c6c, $alpha: 0.5) !important;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure>
<h2 id="默认没有删除按钮-当数据长度大于一时显示"><a href="#默认没有删除按钮-当数据长度大于一时显示" class="headerlink" title="默认没有删除按钮,当数据长度大于一时显示"></a>默认没有删除按钮,当数据长度大于一时显示</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">&lt;div v-for=&quot;(item,index) in formData.centreList&quot; :key=&quot;index&quot; class=&quot;fl w100 clearfix&quot;&gt;</span><br><span class="line">    &lt;div class=&quot;fl w50&quot;&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">    &lt;div :class=&quot;[&#x27;fl&#x27;,formData.centreList.length&gt;1?&#x27;w40&#x27;:&#x27;w50&#x27;]&quot;&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">    &lt;div v-if=&quot;formData.centreList.length&gt;1&quot; class=&quot;fl w10 text_center&quot;&gt;</span><br><span class="line">        &lt;el-form-item label-width=&quot;0&quot;&gt;</span><br><span class="line">            &lt;el-button @click=&quot;deleteStore(index)&quot; type=&quot;danger&quot; icon=&quot;el-icon-delete&quot; circle&gt;&lt;/el-button&gt;</span><br><span class="line">        &lt;/el-form-item&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">&lt;/div&gt;</span><br><span class="line">&lt;style lang=&quot;scss&quot; scoped&gt;</span><br><span class="line">.fl &#123;</span><br><span class="line">    float: left;</span><br><span class="line">&#125;</span><br><span class="line">.w50 &#123;</span><br><span class="line">    width: 50%</span><br><span class="line">&#125;</span><br><span class="line">.clearfix &#123;</span><br><span class="line">    &amp;:after &#123;</span><br><span class="line">        visibility: hidden;</span><br><span class="line">        display: block;</span><br><span class="line">        font-size: 0;</span><br><span class="line">        content: &quot; &quot;;</span><br><span class="line">        clear: both;</span><br><span class="line">        height: 0;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure>
<h2 id="form表单组件化操作"><a href="#form表单组件化操作" class="headerlink" title="form表单组件化操作"></a>form表单组件化操作</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">&lt;el-form size=&quot;small&quot; :disabled=&quot;isDisabled&quot; ref=&quot;form&quot; :model=&quot;formData&quot; label-width=&quot;100px&quot;&gt;</span><br><span class="line">&lt;/el-form&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line">&lt;script&gt;</span><br><span class="line"></span><br><span class="line">export default &#123;</span><br><span class="line">  props: &#123;</span><br><span class="line">    sentFormData: &#123;</span><br><span class="line">      type: Object</span><br><span class="line">    &#125;,</span><br><span class="line">    isDisabled: &#123;</span><br><span class="line">      type: Boolean,</span><br><span class="line">      default: false</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  data() &#123;</span><br><span class="line">    return &#123;</span><br><span class="line">      formData: &#123;</span><br><span class="line">        proposerNameId: &quot;&quot;,</span><br><span class="line">        centreList: [</span><br><span class="line">          &#123;</span><br><span class="line">            warehouseId: &quot;&quot;,</span><br><span class="line">            counterIdList: []</span><br><span class="line">          &#125;</span><br><span class="line">        ]</span><br><span class="line">      &#125;,</span><br><span class="line">      oldFormData: &#123;</span><br><span class="line">        proposerNameId: &quot;&quot;,</span><br><span class="line"></span><br><span class="line">        centreList: [</span><br><span class="line">          &#123;</span><br><span class="line">            warehouseId: &quot;&quot;,</span><br><span class="line">            counterIdList: []</span><br><span class="line">          &#125;</span><br><span class="line">        ]</span><br><span class="line">      &#125;,</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">  created() &#123;</span><br><span class="line">      //请求下拉框数据</span><br><span class="line">    this.fatchData();</span><br><span class="line">  &#125;,</span><br><span class="line">  mounted() &#123;</span><br><span class="line">      //回显</span><br><span class="line">    var data = this.sentFormData;</span><br><span class="line">    if (data) &#123;</span><br><span class="line">      if (Object.keys(data).length == 0) &#123;</span><br><span class="line">        this.formData = this.oldFormData;</span><br><span class="line">      &#125; else &#123;</span><br><span class="line">        this.formData.proposerNameId = data.proposerNameId;</span><br><span class="line">        if (data.associateName) &#123;</span><br><span class="line">          this.formData.associateName = data.associateName.adminId;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        this.formData.taskName = data.taskName;</span><br><span class="line">        this.formData.checkTime = data.checkTime;</span><br><span class="line">        this.formData.checkPurposeId = data.checkPurposeId;</span><br><span class="line">        this.formData.associateNameId = data.associateNameId;</span><br><span class="line">        let centreList = [];</span><br><span class="line">        if (data.centreLists) &#123;</span><br><span class="line">          data.centreLists.map((item, index) =&gt; &#123;</span><br><span class="line">            getObjCodeById(item.warehouseId).then(response =&gt; &#123;</span><br><span class="line">              this.$set(this.collSelect, index, response.data);</span><br><span class="line">            &#125;);</span><br><span class="line">            centreList.push(&#123;</span><br><span class="line">              warehouseId: item.warehouseId,</span><br><span class="line">              counterIdList: item.counterIdList</span><br><span class="line">            &#125;);</span><br><span class="line">          &#125;);</span><br><span class="line">        &#125;</span><br><span class="line">        this.formData.centreList = centreList;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  watch: &#123;</span><br><span class="line">    formData: &#123;</span><br><span class="line">      handler(data) &#123;</span><br><span class="line">        var newData = JSON.parse(JSON.stringify(data));</span><br><span class="line">        this.$emit(&quot;getFormData&quot;, newData);</span><br><span class="line">      &#125;,</span><br><span class="line">      deep: true</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  methods: &#123;</span><br><span class="line">    //父传子 保存时验证方法</span><br><span class="line">    getRulesData() &#123;</span><br><span class="line">      let bl = false;</span><br><span class="line">      this.$refs.form.validate(valid =&gt; &#123;</span><br><span class="line">        bl = valid;</span><br><span class="line">      &#125;);</span><br><span class="line">      return &#123;</span><br><span class="line">        msg: bl ? &quot;表单验证通过&quot; : &quot;请检查输入的表单是否有误&quot;,</span><br><span class="line">        data: bl</span><br><span class="line">      &#125;;</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;,</span><br><span class="line">&lt;script&gt;</span><br></pre></td></tr></table></figure>
<h2 id="头部搜索"><a href="#头部搜索" class="headerlink" title="头部搜索"></a>头部搜索</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">	&lt;el-collapse-transition v-if=&quot;!Boolean(item.hidden)&quot;&gt;</span><br><span class="line">        &lt;li v-for=&quot;(v, i) in item.items&quot; :key=&quot;v.id&quot;&gt;</span><br><span class="line">              &lt;el-button</span><br><span class="line">                v-if=&quot;item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active&quot;</span><br><span class="line">                class=&quot;isRegdateActive&quot;</span><br><span class="line">                @click=&quot;</span><br><span class="line">                  buttonAction(v.id, index,item),</span><br><span class="line">                    item.dataType == &#x27;regdate&#x27; &amp;&amp; dateFormat(v.fieldName, index)</span><br><span class="line">                &quot;</span><br><span class="line">                size=&quot;small&quot;</span><br><span class="line">              &gt;</span><br><span class="line">                &#123;&#123; v.name &#125;&#125;</span><br><span class="line">                  &lt;!--按钮旁边加数字  --&gt;</span><br><span class="line">                &lt;span</span><br><span class="line">                  style=&quot;padding-left: 5px&quot;</span><br><span class="line">                  v-else-if=&quot;</span><br><span class="line">                    sentNumebr &amp;&amp;</span><br><span class="line">                    index &lt; sentNumebr.length &amp;&amp;</span><br><span class="line">                    sentNumebr[index][i] &amp;&amp;</span><br><span class="line">                    sentNumebr[index][i] &gt;= 10000</span><br><span class="line">                  &quot;</span><br><span class="line">                  :title=&quot;v.num&quot;</span><br><span class="line">                  &gt;( &#123;&#123; sentNumebr[index][i] / 10000 +&quot;w&quot;&#125;&#125; )&lt;/span</span><br><span class="line">                &gt;</span><br><span class="line">                  &lt;!--按钮右上方激活打钩  --&gt;</span><br><span class="line">                &lt;div</span><br><span class="line">                  :style=&quot;&#123;</span><br><span class="line">                    height:</span><br><span class="line">                      item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active ? &#x27;16px&#x27; : &#x27;0&#x27;,</span><br><span class="line">                    width:</span><br><span class="line">                      item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active ? &#x27;16px&#x27; : &#x27;0&#x27;,</span><br><span class="line">                    borderTop:</span><br><span class="line">                      item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active</span><br><span class="line">                        ? &#x27;16px solid #39ca74&#x27;</span><br><span class="line">                        : &#x27;0 solid #39ca74&#x27;,</span><br><span class="line">                    borderLeft:</span><br><span class="line">                      item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active</span><br><span class="line">                        ? &#x27;16px solid rgba(0, 0, 0, 0)&#x27;</span><br><span class="line">                        : &#x27;0 solid rgba(0, 0, 0, 0)&#x27;,</span><br><span class="line">                  &#125;&quot;</span><br><span class="line">                  class=&quot;select_data&quot;</span><br><span class="line">                &gt;&lt;/div&gt;</span><br><span class="line">                &lt;div</span><br><span class="line">                  v-if=&quot;item.dataType == &#x27;regdate&#x27; &amp;&amp; v.active&quot;</span><br><span class="line">                  class=&quot;el-icon-check check&quot;</span><br><span class="line">                &gt;&lt;/div&gt;</span><br><span class="line">              &lt;/el-button&gt;</span><br><span class="line">         &lt;/li&gt;</span><br><span class="line">        &lt;!--箭头翻转  --&gt;</span><br><span class="line">        &lt;i</span><br><span class="line">            v-show=&quot;item.iconShow&quot;</span><br><span class="line">            class=&quot;el-icon-arrow-down icon_arrow_style&quot;</span><br><span class="line">            style=&quot;float: right&quot;</span><br><span class="line">            :class=&quot;&#123;</span><br><span class="line">              icon_arrow__ami_default: item.iconDef,</span><br><span class="line">              icon_arrow__ami_rotate: !item.iconDef,</span><br><span class="line">            &#125;&quot;</span><br><span class="line">            @click=&quot;optionMoreCondition(index)&quot;</span><br><span class="line">          &gt;&lt;/i&gt;</span><br><span class="line">    &lt;/el-collapse-transition&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line">&lt;style lang=&quot;scss&quot; scoped&gt;</span><br><span class="line">.isRegdateActive &#123;</span><br><span class="line">  width: 60px;</span><br><span class="line">  color: #39ca74;</span><br><span class="line">  border: 1px solid #39ca74;</span><br><span class="line">  background: #ecf8f0;</span><br><span class="line">  position: relative;</span><br><span class="line">  padding: 0;</span><br><span class="line">  line-height: 32px;</span><br><span class="line">  margin-left: 12px;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.check &#123;</span><br><span class="line">  text-align: center;</span><br><span class="line">  line-height: 1.3em;</span><br><span class="line">  position: absolute;</span><br><span class="line">  top: 4px;</span><br><span class="line">  right: 0px;</span><br><span class="line">  font-size: 1px;</span><br><span class="line">  font-weight: 500;</span><br><span class="line">  color: #fff;</span><br><span class="line">  z-index: 1;</span><br><span class="line">&#125;</span><br><span class="line">.icon_arrow_style &#123;</span><br><span class="line">  position: absolute;</span><br><span class="line">  top: 50%;</span><br><span class="line">  right: 10px;</span><br><span class="line">  margin-top: -8px;</span><br><span class="line">  cursor: pointer;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure>
<h2 id="百度地图-＜baidu-map＞"><a href="#百度地图-＜baidu-map＞" class="headerlink" title="百度地图(＜baidu-map＞)"></a>百度地图(＜baidu-map＞)</h2><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm i vue-baidu-map --save</span><br></pre></td></tr></table></figure>
<h3 id="引入-1"><a href="#引入-1" class="headerlink" title="引入"></a>引入</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 百度地图 Start*/</span></span><br><span class="line"><span class="keyword">import</span> <span class="title class_">BaiduMap</span> <span class="keyword">from</span> <span class="string">&#x27;vue-baidu-map&#x27;</span></span><br><span class="line"><span class="title class_">Vue</span>.<span class="title function_">use</span>(<span class="title class_">BaiduMap</span>, &#123;</span><br><span class="line">    <span class="attr">ak</span>: <span class="string">&#x27;bc4d824e9c0fef9cc375e45deace61d9&#x27;</span> <span class="comment">//官方提供的ak秘钥</span></span><br><span class="line">&#125;)</span><br><span class="line"><span class="comment">/* 百度地图 End*/</span></span><br></pre></td></tr></table></figure>
<h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;baidu-map</span><br><span class="line">    class=&quot;map&quot;</span><br><span class="line">    :center=&quot;arrObj[0].center&quot;</span><br><span class="line">    :zoom=&quot;zoom&quot;</span><br><span class="line">    :scroll-wheel-zoom=&quot;true&quot;</span><br><span class="line">    style=&quot;height: 100%; width: 100%&quot;</span><br><span class="line">    @ready=&quot;handler&quot;</span><br><span class="line">    @click=&quot;getClickInfo&quot;</span><br><span class="line">  &gt;</span><br><span class="line">    &lt;bm-marker</span><br><span class="line">      v-for=&quot;(obj, index) in arrObj&quot;</span><br><span class="line">      :key=&quot;index&quot;</span><br><span class="line">      :position=&quot;obj.center&quot;</span><br><span class="line">      :dragging=&quot;true&quot;</span><br><span class="line">      animation=&quot;BMAP_ANIMATION_BOUNCE&quot;</span><br><span class="line">    &gt;</span><br><span class="line">      &lt;bm-label</span><br><span class="line">        :content=&quot;obj.title&quot;</span><br><span class="line">        :labelStyle=&quot;&#123; color: &#x27;red&#x27;, fontSize: &#x27;16px&#x27; &#125;&quot;</span><br><span class="line">        :offset=&quot;obj.box&quot;</span><br><span class="line">      /&gt;</span><br><span class="line"></span><br><span class="line">      &lt;!-- 必须给容器指高度，不然地图将显示在一个高度为0的容器中，看不到 --&gt;</span><br><span class="line">      &lt;bm-navigation anchor=&quot;BMAP_ANCHOR_TOP_RIGHT&quot;&gt;&lt;/bm-navigation&gt;</span><br><span class="line">      &lt;bm-geolocation</span><br><span class="line">        anchor=&quot;BMAP_ANCHOR_BOTTOM_RIGHT&quot;</span><br><span class="line">        :showAddressBar=&quot;true&quot;</span><br><span class="line">        :autoLocation=&quot;true&quot;</span><br><span class="line">      &gt;&lt;/bm-geolocation&gt;</span><br><span class="line">      &lt;bm-city-list anchor=&quot;BMAP_ANCHOR_TOP_LEFT&quot;&gt;&lt;/bm-city-list&gt;</span><br><span class="line"></span><br><span class="line">      &lt;!-- 因为我采用的是全局注册，所以不用再在该页面上注册components --&gt;</span><br><span class="line">    &lt;/bm-marker&gt;</span><br><span class="line">  &lt;/baidu-map&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line">export default &#123;</span><br><span class="line">  name: &quot;MapBaidu&quot;,</span><br><span class="line">  props: &#123;</span><br><span class="line">    sentData: &#123;</span><br><span class="line">      type: Array,</span><br><span class="line">      default: function () &#123;</span><br><span class="line">        return [</span><br><span class="line">           &#123;</span><br><span class="line">          title: &quot;广州海事博物馆&quot;,</span><br><span class="line">          center: &#123; lng: 113.508252, lat: 23.084856 &#125;,</span><br><span class="line">          box: &#123; width: -40, height: -30 &#125;,</span><br><span class="line">          zoom: 20,</span><br><span class="line">        &#125;,</span><br><span class="line">        ];</span><br><span class="line">      &#125;,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">  data() &#123;</span><br><span class="line">    return &#123;</span><br><span class="line">      center: &#123; lng: 0, lat: 0 &#125;, //经纬度</span><br><span class="line">      zoom: 20000, //地图展示级别</span><br><span class="line">      arrObj: [],</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">  watch: &#123;</span><br><span class="line">    sentData: &#123;</span><br><span class="line">      handler(newVal) &#123;</span><br><span class="line">        this.arrObj=newVal</span><br><span class="line">        this.$set(this.center, &quot;lng&quot;, newVal[0].center);</span><br><span class="line">      &#125;,</span><br><span class="line">      deep: true,</span><br><span class="line">      immediate: true,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">  methods: &#123;</span><br><span class="line">    handler(&#123; BMap, map &#125;) &#123;</span><br><span class="line">      /*  console.log(BMap, map); */</span><br><span class="line">     </span><br><span class="line">      this.zoom = this.zoom;</span><br><span class="line">    &#125;,</span><br><span class="line">    getClickInfo(e) &#123;</span><br><span class="line">      /*   console.log(e.point.lng);</span><br><span class="line">      console.log(e.point.lat);</span><br><span class="line">      this.center.lng = e.point.lng;</span><br><span class="line">      this.center.lat = e.point.lat; */</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="二次确认-confirm"><a href="#二次确认-confirm" class="headerlink" title="二次确认,$confirm"></a>二次确认,$confirm</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//收藏藏品</span></span><br><span class="line"><span class="title function_">setCollect</span>(<span class="params"></span>) &#123;</span><br><span class="line">    <span class="variable language_">this</span>.$confirm(<span class="string">&quot;是否收藏该藏品?&quot;</span>, <span class="string">&quot;提示&quot;</span>, &#123;</span><br><span class="line">        <span class="attr">confirmButtonText</span>: <span class="string">&quot;确定&quot;</span>,</span><br><span class="line">        <span class="attr">cancelButtonText</span>: <span class="string">&quot;取消&quot;</span>,</span><br><span class="line">        <span class="attr">type</span>: <span class="string">&quot;warning&quot;</span>,</span><br><span class="line">    &#125;)</span><br><span class="line">        .<span class="title function_">then</span>(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">        <span class="title function_">setCollectById</span>(<span class="variable language_">this</span>.<span class="property">getSelectIDData</span>).<span class="title function_">then</span>(<span class="function">(<span class="params">res</span>) =&gt;</span> &#123;</span><br><span class="line">            <span class="variable language_">this</span>.<span class="title function_">successDailogMessage</span>(<span class="string">&quot;收藏成功&quot;</span>);</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;)</span><br><span class="line">        .<span class="title function_">catch</span>(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">        <span class="variable language_">this</span>.$message(&#123;</span><br><span class="line">            <span class="attr">type</span>: <span class="string">&quot;info&quot;</span>,</span><br><span class="line">            <span class="attr">message</span>: <span class="string">&quot;已取消&quot;</span>,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;,</span><br></pre></td></tr></table></figure>
<h2 id="分片上传、秒传及断点续传"><a href="#分片上传、秒传及断点续传" class="headerlink" title="分片上传、秒传及断点续传"></a>分片上传、秒传及断点续传</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//安装插件</span></span><br><span class="line">npm install vue-simple-uploader --save</span><br><span class="line">m install --save spark-md5</span><br><span class="line"><span class="comment">//引用</span></span><br><span class="line"><span class="keyword">import</span> uploader <span class="keyword">from</span> <span class="string">&#x27;vue-simple-uploader&#x27;</span></span><br><span class="line"><span class="title class_">Vue</span>.<span class="title function_">use</span>(uploader)</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="title class_">SparkMd5</span> <span class="keyword">from</span> <span class="string">&quot;spark-md5&quot;</span>;</span><br><span class="line"><span class="title class_">Vue</span>.<span class="property"><span class="keyword">prototype</span></span>.<span class="property">SparkMd5</span> = <span class="title class_">SparkMd5</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">//源码使用</span></span><br><span class="line">src\components\<span class="title class_">UCondition</span>\resourcesUpload.<span class="property">vue</span></span><br></pre></td></tr></table></figure>
<h2 id="Vue——右键弹出菜单-vue-contextmenu"><a href="#Vue——右键弹出菜单-vue-contextmenu" class="headerlink" title="Vue——右键弹出菜单(vue-contextmenu)"></a>Vue——右键弹出菜单(vue-contextmenu)</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//安装：</span></span><br><span class="line">npm install vue-contextmenu --save</span><br><span class="line"><span class="comment">//引入：</span></span><br><span class="line"><span class="keyword">import</span> <span class="title class_">VueContextMenu</span> <span class="keyword">from</span> <span class="string">&#x27;vue-contextmenu&#x27;</span></span><br><span class="line"><span class="title class_">Vue</span>.<span class="title function_">use</span>(<span class="title class_">VueContextMenu</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">//使用：</span></span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">&lt;div id=&quot;app&quot; @contextmenu=&quot;showMenu&quot;</span><br><span class="line">    style=&quot;width: 100px;height: 100px;margin-top: 20px;background: red;&quot;&gt;</span><br><span class="line">    &lt;vue-context-menu :contextMenuData=&quot;contextMenuData&quot;</span><br><span class="line">        @home=&quot;home&quot;</span><br><span class="line">        @deletedata=&quot;deletedata&quot;&gt;&lt;/vue-context-menu&gt;</span><br><span class="line">&lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line">&lt;script&gt;</span><br><span class="line">export default &#123;</span><br><span class="line">  name: &#x27;app&#x27;,</span><br><span class="line">  data () &#123;</span><br><span class="line">    return &#123;</span><br><span class="line">    // 菜单数据</span><br><span class="line">       contextMenuData: &#123;</span><br><span class="line">         menuName: &#x27;demo&#x27;,</span><br><span class="line">         //菜单显示的位置</span><br><span class="line">         axis: &#123;</span><br><span class="line">           x: null,</span><br><span class="line">           y: null</span><br><span class="line">         &#125;,</span><br><span class="line">         //菜单选项</span><br><span class="line">         menulists: [&#123;</span><br><span class="line">           fnHandler: &#x27;home&#x27;, //绑定事件</span><br><span class="line">           icoName: &#x27;fa fa-home fa-fw&#x27;, //icon图标</span><br><span class="line">           btnName: &#x27;回到主页&#x27; //菜单名称</span><br><span class="line">         &#125;, &#123;</span><br><span class="line">             fnHandler: &#x27;deletedata&#x27;,</span><br><span class="line">             icoName: &#x27;fa fa-minus-square-o  fa-fw&#x27;,</span><br><span class="line">             btnName: &#x27;删除布局&#x27;</span><br><span class="line">         &#125;]</span><br><span class="line">       &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  methods: &#123;</span><br><span class="line">    showMenu () &#123;</span><br><span class="line">        event.preventDefault()</span><br><span class="line">        var x = event.clientX</span><br><span class="line">        var y = event.clientY</span><br><span class="line">        // Get the current location</span><br><span class="line">      this.contextMenuData.axis = &#123;</span><br><span class="line">        x, y</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    homed () &#123;</span><br><span class="line">      alert(&quot;主页&quot;)</span><br><span class="line">    &#125;,</span><br><span class="line">    deletedata () &#123;</span><br><span class="line">      console.log(&#x27;delete!&#x27;)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>
<h2 id="element-ui-为内数据-添加数字千位分割符10-000"><a href="#element-ui-为内数据-添加数字千位分割符10-000" class="headerlink" title="element-ui 为内数据 添加数字千位分割符10,000"></a><a target="_blank" rel="noopener" href="https://www.cnblogs.com/taoshaoji/p/elementUI_.html">element-ui 为内数据 添加数字千位分割符10,000</a></h2><h2 id="vue图片点击放大预览v-viewer"><a href="#vue图片点击放大预览v-viewer" class="headerlink" title="vue图片点击放大预览v-viewer"></a><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/84042c7b1b5b">vue图片点击放大预览v-viewer</a></h2><h2 id="基于Vue实现可以拖拽的树形表格"><a href="#基于Vue实现可以拖拽的树形表格" class="headerlink" title="基于Vue实现可以拖拽的树形表格"></a><a target="_blank" rel="noopener" href="https://www.cnblogs.com/bfgis/p/9805928.html">基于Vue实现可以拖拽的树形表格</a></h2><h2 id="Vue图片放大镜插件"><a href="#Vue图片放大镜插件" class="headerlink" title="Vue图片放大镜插件"></a><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_40631679/article/details/107272569">Vue图片放大镜插件</a></h2><h2 id="使用vuetify-UI框架"><a href="#使用vuetify-UI框架" class="headerlink" title="使用vuetify UI框架"></a>使用vuetify UI框架</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">cnpm install vuetify</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="title class_">Vuetify</span> <span class="keyword">from</span> <span class="string">&#x27;vuetify&#x27;</span> <span class="comment">// 使用vuetify UI框架</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;vuetify/dist/vuetify.min.css&#x27;</span> <span class="comment">// 导入 vuetify样式</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;./assets/styles/index.scss&#x27;</span> <span class="comment">// 导入 vuetify样式</span></span><br><span class="line"><span class="title class_">Vue</span>.<span class="title function_">use</span>(<span class="title class_">Vuetify</span>) <span class="comment">// 使用 vuetify</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="keyword">new</span> <span class="title class_">Vuetify</span>(&#123;&#125;) <span class="comment">// 导出vuetify对象 不然会报错</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">new</span> <span class="title class_">Vue</span>(&#123;</span><br><span class="line">  router,</span><br><span class="line">  store,</span><br><span class="line">  <span class="attr">vuetify</span>: <span class="keyword">new</span> <span class="title class_">Vuetify</span>(),</span><br><span class="line">  <span class="attr">render</span>: <span class="function"><span class="params">h</span> =&gt;</span> <span class="title function_">h</span>(<span class="title class_">App</span>)</span><br><span class="line">&#125;).$mount(<span class="string">&#x27;#app&#x27;</span>)</span><br></pre></td></tr></table></figure>
<h2 id="使用swiper框架"><a href="#使用swiper框架" class="headerlink" title="使用swiper框架"></a>使用swiper框架</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cnpm install swiper@<span class="number">3.4</span><span class="number">.2</span> --save-dev</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="title class_">Swiper</span> <span class="keyword">from</span> <span class="string">&quot;swiper&quot;</span>;</span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;swiper/dist/css/swiper.css&#x27;</span>;</span><br></pre></td></tr></table></figure>
<h1 id="手机端适配"><a href="#手机端适配" class="headerlink" title="手机端适配"></a>手机端适配</h1><h2 id="起手是使用-响应式栅格xs、sm、md、lg-和-xl"><a href="#起手是使用-响应式栅格xs、sm、md、lg-和-xl" class="headerlink" title="起手是使用 响应式栅格xs、sm、md、lg 和 xl"></a>起手是使用 响应式栅格<code>xs、sm、md、lg 和 xl</code></h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line">methods: &#123;</span><br><span class="line">    onResize() &#123;</span><br><span class="line">		//存储数据到vuex</span><br><span class="line">        this.$store.dispatch(&#123;</span><br><span class="line">            type: &quot;changeBrowserStyle&quot;,</span><br><span class="line">            data: window.innerWidth,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;,</span><br><span class="line">&#125;,</span><br><span class="line">beforeMount() &#123;</span><br><span class="line">	//监听屏幕变化</span><br><span class="line">    this.onResize();</span><br><span class="line">    window.addEventListener(&quot;resize&quot;, this.onResize, &#123; passive: true &#125;);</span><br><span class="line">&#125;,</span><br><span class="line">destroyed() &#123;</span><br><span class="line">	window.removeEventListener(&quot;resize&quot;, this.onResize);</span><br><span class="line">&#125;,</span><br><span class="line">    </span><br><span class="line">//vuex</span><br><span class="line">&#123;</span><br><span class="line">  state: &#123;</span><br><span class="line">    mobile: false,</span><br><span class="line">  &#125;,</span><br><span class="line">  getters: &#123;</span><br><span class="line">    isMobile: state =&gt; &#123;</span><br><span class="line">      return state.mobile</span><br><span class="line">  	&#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">  mutations: &#123;</span><br><span class="line">    change_BrowserStyle(state, obj) &#123;</span><br><span class="line"></span><br><span class="line">      // 变更状态</span><br><span class="line">      if (obj.data &lt; 600) &#123;</span><br><span class="line">        state.mobile = true;</span><br><span class="line">      &#125;</span><br><span class="line">      if (obj.data &gt;= 600 &amp;&amp; obj.data &lt; 960) &#123;</span><br><span class="line">        state.mobile = true;</span><br><span class="line">      &#125;</span><br><span class="line">      if (obj.data &gt;= 960 &amp;&amp; obj.data &lt; 1264) &#123;</span><br><span class="line">        state.mobile = false;</span><br><span class="line">      &#125;</span><br><span class="line">      if (obj.data &gt;= 1264 &amp;&amp; obj.data &lt; 1904) &#123;</span><br><span class="line">        state.mobile = false;</span><br><span class="line">      &#125;</span><br><span class="line">      if (obj.data &gt;= 1904) &#123;</span><br><span class="line">        state.mobile = false;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;,</span><br><span class="line">  actions: &#123;</span><br><span class="line">    changeBrowserStyle(&#123; commit &#125;, obj) &#123;</span><br><span class="line">      commit(&#x27;change_BrowserStyle&#x27;, obj)</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>
<h1 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h1><h2 id="为什么选择Vue？"><a href="#为什么选择Vue？" class="headerlink" title="为什么选择Vue？"></a>为什么选择Vue？</h2><p>Vue的三大特性：</p>
<p>　　易用：是中国人写的,有好的中文文档,容易上手,市面上的招聘多</p>
<p>　　灵活：可以在库和框架之间灵活切换，这个也是Vue 的渐进式而言</p>
<p>　　高效：20KB运行大小；超快的虚拟dom</p>
<h2 id="vue解决了什么"><a href="#vue解决了什么" class="headerlink" title="vue解决了什么"></a>vue解决了什么</h2><p>然后开始学习ECMAScript6，Webpack，NPM以及Vue-Cli的基本用法，最好对Node.js也要有所了解。</p>
<h2 id="vue生命周期"><a href="#vue生命周期" class="headerlink" title="vue生命周期"></a>vue生命周期</h2><p>beforeCreate(创建前):可以在这加个loading事件，在加载实例时触发</p>
<p>created(创建后):请求数据,获取数据,数据的回显</p>
<p>beforeMount(载入前) :</p>
<p>mounted(载入后) :cavas</p>
<p>beforeUpdate(更新前) </p>
<p>updated（更新后) </p>
<p>beforeDestroy(销毁前) :自定义的一些方法,释放内存</p>
<p>destroyed（销毁后)</p>
<p>this.$<em>nextTick</em>():获取输入框的焦点</p>
<h2 id="v-if跟v-show的区别"><a href="#v-if跟v-show的区别" class="headerlink" title="v-if跟v-show的区别"></a>v-if跟v-show的区别</h2><h2 id="vue组件通信几种方式"><a href="#vue组件通信几种方式" class="headerlink" title="vue组件通信几种方式"></a>vue组件通信几种方式</h2><p>content,introduce,stayCondition,mainBody,activityContent,details,overViewContent,questContent</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">ZhuoRu</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://zhangzhuoru.gitee.io/web/post/16106.html">https://zhangzhuoru.gitee.io/web/post/16106.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://zhangzhuoru.gitee.io/web" target="_blank">前端攻城狮ZhuoRu</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/web/tags/web/">web</a></div><div class="post_share"><div class="social-share" data-image="/web/img/tab99.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/web/./img/wechat.png" target="_blank"><img class="post-qr-code-img" data-lazy-src="/web/./img/wechat.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/web/./img/alipay.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/web/./img/alipay.jpg" alt="支付寶"/></a><div class="post-qr-code-desc">支付寶</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/web/post/1024.html"><img class="prev-cover" data-lazy-src="/web/img/tab2.png" onerror="onerror=null;src='/web/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">话费充值平台总结</div></div></a></div><div class="next-post pull-right"><a href="/web/post/11314.html"><img class="next-cover" data-lazy-src="/web/img/tab5.png" onerror="onerror=null;src='/web/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">uniapp开发,遇坑填坑 😘</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/web/post/16107.html" title="Butterfly启动说明书"><img class="cover" data-lazy-src="/web/img/tab6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-27</div><div class="title">Butterfly启动说明书</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="https://thirdqq.qlogo.cn/g?b=sdk&amp;nk=2276839311&amp;s=140" onerror="this.onerror=null;this.src='/web/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">ZhuoRu</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/web/archives/"><div class="headline">文章</div><div class="length-num">8</div></a></div><div class="card-info-data-item is-center"><a href="/web/tags/"><div class="headline">标签</div><div class="length-num">9</div></a></div><div class="card-info-data-item is-center"><a href="/web/categories/"><div class="headline">分类</div><div class="length-num">5</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/WebZhuoRu"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/WebZhuoRu" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2276839311@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://webzhuoru.github.io/" target="_blank" title="博客"><i class="fa-solid fa-book-skull"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%AF%E5%9B%AD%E5%A1%AB%E5%9D%91%E5%9B%9E%E5%BF%86%E5%BD%95"><span class="toc-number">1.</span> <span class="toc-text">可园填坑回忆录</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#vue%E4%B8%AD%E7%82%B9%E5%87%BB%E4%B8%8D%E5%8F%AF%E7%94%A8-%E4%B8%80%E8%88%AC%E9%83%BD%E6%98%AF%E8%87%AA%E5%B8%A6%E4%BA%86if%E9%99%90%E5%88%B6%E6%9D%A1%E4%BB%B6"><span class="toc-number">1.1.</span> <span class="toc-text">vue中点击不可用,一般都是自带了if限制条件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AF%B7%E6%B1%82%E5%8F%91%E5%87%BA%E5%8E%BB%E4%BA%86-%E5%90%8E%E5%8F%B0%E6%94%B6%E4%B8%8D%E5%88%B0-%E5%8F%AF%E8%83%BD%E6%98%AF%E8%AF%B7%E6%B1%82%E5%A4%B4%E6%A0%BC%E5%BC%8F%E9%94%99%E8%AF%AF"><span class="toc-number">1.2.</span> <span class="toc-text">请求发出去了,后台收不到,可能是请求头格式错误</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BD%93%E5%89%8D%E9%A1%B5%E9%9D%A2%E6%9F%A5%E4%B8%8D%E5%88%B0%E5%85%83%E7%B4%A0-%E5%8F%AF%E4%BB%A5%E5%8E%BB%E5%85%A8%E5%B1%80%E6%90%9C%E7%B4%A2-%E6%9F%A5%E6%89%BE%E6%89%80%E6%9C%89%E6%96%87%E4%BB%B6"><span class="toc-number">1.3.</span> <span class="toc-text">当前页面查不到元素,可以去全局搜索,查找所有文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%BE%E7%89%87%E4%B8%8B%E8%BD%BD%E6%9C%89%E4%B8%A4%E7%A7%8D-%E4%B8%80%E7%A7%8D%E6%98%AF%E6%96%87%E4%BB%B6%E6%B5%81-%E6%B2%A1%E8%AF%95%E8%BF%87-%E6%9C%80%E5%A4%9A%E7%9A%84%E5%B0%B1%E6%98%AF%E8%B7%AF%E5%BE%84%E6%8B%BC%E6%8E%A5"><span class="toc-number">1.4.</span> <span class="toc-text">图片下载有两种,一种是文件流,没试过,最多的就是路径拼接,</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E7%9A%84%E5%9B%BE%E7%89%87%E6%97%A0%E6%B3%95%E4%BF%9D%E5%AD%98%E8%BF%9B%E6%95%B0%E6%8D%AE%E5%BA%93-%E4%B8%80%E6%98%AF%E4%B8%8A%E4%BC%A0%E4%B8%8D%E8%83%BD%E4%BC%A0%E5%8F%82-%E4%BA%8C%E6%98%AF%E6%9C%AA%E5%9B%9E%E6%98%BE%E8%AF%B7%E6%B1%82%E5%9B%9E%E7%9A%84%E6%95%B0%E6%8D%AE"><span class="toc-number">1.5.</span> <span class="toc-text">上传的图片无法保存进数据库,一是上传不能传参,二是未回显请求回的数据</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#el-date-picker-%E6%97%A0%E6%B3%95%E4%BF%AE%E6%94%B9%E6%97%B6%E9%97%B4"><span class="toc-number">1.6.</span> <span class="toc-text">el-date-picker 无法修改时间</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E8%BA%AB%E4%BB%BD%E8%AF%81-%E7%88%B6%E5%AD%90%E7%BB%84%E4%BB%B6%E6%95%B0%E6%8D%AE%E6%97%A0%E6%B3%95%E5%90%8C%E6%AD%A5-%E5%BC%82%E6%AD%A5%E6%97%B6"><span class="toc-number">1.7.</span> <span class="toc-text">上传身份证 父子组件数据无法同步,异步时</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BD%93%E5%90%8E%E7%AB%AF%E9%9C%80%E8%A6%81%E5%8F%82%E6%95%B0%E8%A6%81%E5%AE%9A%E5%88%B6"><span class="toc-number">1.8.</span> <span class="toc-text">当后端需要参数要定制</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E7%BB%84%E8%BD%AC%E5%AD%97%E7%AC%A6%E4%B8%B2"><span class="toc-number">1.9.</span> <span class="toc-text">数组转字符串</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Object-keys-%E5%8F%AF%E6%B5%85%E6%8B%B7%E8%B4%9D"><span class="toc-number">2.</span> <span class="toc-text">Object.keys 可浅拷贝</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AF%AD%E6%B3%95"><span class="toc-number">2.1.</span> <span class="toc-text">语法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8F%82%E6%95%B0"><span class="toc-number">2.1.1.</span> <span class="toc-text">参数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%94%E5%9B%9E%E5%80%BC"><span class="toc-number">2.1.2.</span> <span class="toc-text">返回值</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8F%8F%E8%BF%B0"><span class="toc-number">2.2.</span> <span class="toc-text">描述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BE%8B%E5%AD%90"><span class="toc-number">2.3.</span> <span class="toc-text">例子</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E5%90%88%E6%B5%85%E6%8B%B7%E8%B4%9D"><span class="toc-number">2.4.</span> <span class="toc-text">配合浅拷贝</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%95%B0%E7%BB%84%E5%B8%B8%E8%A7%81%E4%BD%BF%E7%94%A8"><span class="toc-number">3.</span> <span class="toc-text">数组常见使用</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#find-%E8%BF%94%E5%9B%9E%E7%AC%A6%E5%90%88%E6%9D%A1%E4%BB%B6%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%85%83%E7%B4%A0"><span class="toc-number">3.1.</span> <span class="toc-text">find 返回符合条件的第一个元素</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#findIndex-%E8%BF%94%E5%9B%9E%E7%AC%A6%E5%90%88%E6%9D%A1%E4%BB%B6%E7%9A%84%E4%B8%8B%E6%A0%87"><span class="toc-number">3.2.</span> <span class="toc-text">findIndex() 返回符合条件的下标</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#filter-%E8%BF%87%E6%BB%A4-%E8%BF%94%E5%9B%9E%E7%AC%A6%E5%90%88%E6%9D%A1%E4%BB%B6%E7%9A%84%E6%96%B0%E6%95%B0%E7%BB%84%E3%80%82"><span class="toc-number">3.3.</span> <span class="toc-text">filter() 过滤, 返回符合条件的新数组。</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#join-%E8%BF%94%E5%9B%9E%E6%8B%BC%E6%8E%A5%E5%AD%97%E7%AC%A6%E4%B8%B2"><span class="toc-number">3.4.</span> <span class="toc-text">join() 返回拼接字符串</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#reduce-%E7%B4%AF%E5%8A%A0"><span class="toc-number">3.5.</span> <span class="toc-text">reduce  累加</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#splice-%E5%8F%AF%E5%88%A0%E9%99%A4-%E6%9B%BF%E6%8D%A2%E6%88%96%E6%B7%BB%E5%8A%A0%E6%96%B0%E7%9A%84%E5%85%83%E7%B4%A0%E6%9D%A5%E4%BF%AE%E6%94%B9%E6%95%B0%E7%BB%84-%E4%BC%9A%E6%94%B9%E5%8F%98%E5%8E%9F%E6%95%B0%E7%BB%84"><span class="toc-number">3.6.</span> <span class="toc-text">splice()  可删除,替换或添加新的元素来修改数组,会改变原数组</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#forEach-%E6%88%96map%E6%96%B9%E6%B3%95%E5%AF%B9%E6%95%B0%E7%BB%84%E7%9A%84%E6%AF%8F%E4%B8%AA%E5%85%83%E7%B4%A0%E6%89%A7%E8%A1%8C%E4%B8%80%E6%AC%A1%E7%BB%99%E5%AE%9A%E7%9A%84%E5%87%BD%E6%95%B0%E3%80%82%E5%BE%AA%E7%8E%AF"><span class="toc-number">3.7.</span> <span class="toc-text">forEach() 或map方法对数组的每个元素执行一次给定的函数。循环</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#reverse-%E4%BD%8D%E7%BD%AE%E9%A2%A0%E5%80%92%EF%BC%8C%E8%AF%A5%E6%96%B9%E6%B3%95%E4%BC%9A%E6%94%B9%E5%8F%98%E5%8E%9F%E6%95%B0%E7%BB%84%E3%80%82"><span class="toc-number">3.8.</span> <span class="toc-text">reverse() 位置颠倒，该方法会改变原数组。</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#sort-%E6%8E%92%E5%BA%8F%EF%BC%8C%E9%BB%98%E8%AE%A4%E6%8E%92%E5%BA%8F%E9%A1%BA%E5%BA%8F%E6%98%AF%E5%9C%A8%E5%B0%86%E5%85%83%E7%B4%A0%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E7%84%B6%E5%90%8E%E6%AF%94%E8%BE%83%E5%AE%83%E4%BB%AC%E7%9A%84UTF-16%E4%BB%A3%E7%A0%81%E5%8D%95%E5%85%83%E5%80%BC%E5%BA%8F%E5%88%97%E6%97%B6%E6%9E%84%E5%BB%BA%E7%9A%84"><span class="toc-number">3.9.</span> <span class="toc-text">sort() 排序，默认排序顺序是在将元素转换为字符串，然后比较它们的UTF-16代码单元值序列时构建的</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%92%E5%8A%A9%E5%8F%AF%E5%8F%96%E4%B9%8B%E5%A4%84"><span class="toc-number">4.</span> <span class="toc-text">互助可取之处</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E4%B8%AD%E8%A6%81%E6%B1%82%E5%8F%AF%E4%BB%A5%E6%8B%96%E6%8B%BDelement-UI-table-%E7%9A%84%E8%A1%A8%E6%A0%BC"><span class="toc-number">4.1.</span> <span class="toc-text">项目中要求可以拖拽element UI table 的表格</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8-sortablejs-%E6%8F%92%E4%BB%B6"><span class="toc-number">4.1.1.</span> <span class="toc-text">使用 sortablejs 插件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%95%E5%85%A5"><span class="toc-number">4.1.2.</span> <span class="toc-text">引入</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81"><span class="toc-number">4.1.3.</span> <span class="toc-text">代码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%BB%98%E8%AE%A4%E6%B2%A1%E6%9C%89%E5%88%A0%E9%99%A4%E6%8C%89%E9%92%AE-%E5%BD%93%E6%95%B0%E6%8D%AE%E9%95%BF%E5%BA%A6%E5%A4%A7%E4%BA%8E%E4%B8%80%E6%97%B6%E6%98%BE%E7%A4%BA"><span class="toc-number">4.2.</span> <span class="toc-text">默认没有删除按钮,当数据长度大于一时显示</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#form%E8%A1%A8%E5%8D%95%E7%BB%84%E4%BB%B6%E5%8C%96%E6%93%8D%E4%BD%9C"><span class="toc-number">4.3.</span> <span class="toc-text">form表单组件化操作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%B4%E9%83%A8%E6%90%9C%E7%B4%A2"><span class="toc-number">4.4.</span> <span class="toc-text">头部搜索</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE-%EF%BC%9Cbaidu-map%EF%BC%9E"><span class="toc-number">4.5.</span> <span class="toc-text">百度地图(＜baidu-map＞)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">4.5.1.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%95%E5%85%A5-1"><span class="toc-number">4.5.2.</span> <span class="toc-text">引入</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8"><span class="toc-number">4.5.3.</span> <span class="toc-text">使用</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%E6%AC%A1%E7%A1%AE%E8%AE%A4-confirm"><span class="toc-number">4.6.</span> <span class="toc-text">二次确认,$confirm</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%86%E7%89%87%E4%B8%8A%E4%BC%A0%E3%80%81%E7%A7%92%E4%BC%A0%E5%8F%8A%E6%96%AD%E7%82%B9%E7%BB%AD%E4%BC%A0"><span class="toc-number">4.7.</span> <span class="toc-text">分片上传、秒传及断点续传</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Vue%E2%80%94%E2%80%94%E5%8F%B3%E9%94%AE%E5%BC%B9%E5%87%BA%E8%8F%9C%E5%8D%95-vue-contextmenu"><span class="toc-number">4.8.</span> <span class="toc-text">Vue——右键弹出菜单(vue-contextmenu)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#element-ui-%E4%B8%BA%E5%86%85%E6%95%B0%E6%8D%AE-%E6%B7%BB%E5%8A%A0%E6%95%B0%E5%AD%97%E5%8D%83%E4%BD%8D%E5%88%86%E5%89%B2%E7%AC%A610-000"><span class="toc-number">4.9.</span> <span class="toc-text">element-ui 为内数据 添加数字千位分割符10,000</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vue%E5%9B%BE%E7%89%87%E7%82%B9%E5%87%BB%E6%94%BE%E5%A4%A7%E9%A2%84%E8%A7%88v-viewer"><span class="toc-number">4.10.</span> <span class="toc-text">vue图片点击放大预览v-viewer</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E4%BA%8EVue%E5%AE%9E%E7%8E%B0%E5%8F%AF%E4%BB%A5%E6%8B%96%E6%8B%BD%E7%9A%84%E6%A0%91%E5%BD%A2%E8%A1%A8%E6%A0%BC"><span class="toc-number">4.11.</span> <span class="toc-text">基于Vue实现可以拖拽的树形表格</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Vue%E5%9B%BE%E7%89%87%E6%94%BE%E5%A4%A7%E9%95%9C%E6%8F%92%E4%BB%B6"><span class="toc-number">4.12.</span> <span class="toc-text">Vue图片放大镜插件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8vuetify-UI%E6%A1%86%E6%9E%B6"><span class="toc-number">4.13.</span> <span class="toc-text">使用vuetify UI框架</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8swiper%E6%A1%86%E6%9E%B6"><span class="toc-number">4.14.</span> <span class="toc-text">使用swiper框架</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%89%8B%E6%9C%BA%E7%AB%AF%E9%80%82%E9%85%8D"><span class="toc-number">5.</span> <span class="toc-text">手机端适配</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B5%B7%E6%89%8B%E6%98%AF%E4%BD%BF%E7%94%A8-%E5%93%8D%E5%BA%94%E5%BC%8F%E6%A0%85%E6%A0%BCxs%E3%80%81sm%E3%80%81md%E3%80%81lg-%E5%92%8C-xl"><span class="toc-number">5.1.</span> <span class="toc-text">起手是使用 响应式栅格xs、sm、md、lg 和 xl</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98"><span class="toc-number">6.</span> <span class="toc-text">常见问题</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E9%80%89%E6%8B%A9Vue%EF%BC%9F"><span class="toc-number">6.1.</span> <span class="toc-text">为什么选择Vue？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vue%E8%A7%A3%E5%86%B3%E4%BA%86%E4%BB%80%E4%B9%88"><span class="toc-number">6.2.</span> <span class="toc-text">vue解决了什么</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vue%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F"><span class="toc-number">6.3.</span> <span class="toc-text">vue生命周期</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#v-if%E8%B7%9Fv-show%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-number">6.4.</span> <span class="toc-text">v-if跟v-show的区别</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vue%E7%BB%84%E4%BB%B6%E9%80%9A%E4%BF%A1%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F"><span class="toc-number">6.5.</span> <span class="toc-text">vue组件通信几种方式</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/web/post/1026.html" title="Vue3学习总结"><img data-lazy-src="/web/img/tab99.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="Vue3学习总结"/></a><div class="content"><a class="title" href="/web/post/1026.html" title="Vue3学习总结">Vue3学习总结</a><time datetime="2022-11-26T16:31:04.834Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/web/post/1666.html" title="个人简历大全 😘"><img data-lazy-src="/web/img/tab4.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="个人简历大全 😘"/></a><div class="content"><a class="title" href="/web/post/1666.html" title="个人简历大全 😘">个人简历大全 😘</a><time datetime="2022-11-26T16:31:04.810Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/web/post/1024.html" title="话费充值平台总结"><img data-lazy-src="/web/img/tab2.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="话费充值平台总结"/></a><div class="content"><a class="title" href="/web/post/1024.html" title="话费充值平台总结">话费充值平台总结</a><time datetime="2022-11-26T16:31:04.798Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/web/post/16106.html" title="填坑录"><img data-lazy-src="/web/img/tab99.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="填坑录"/></a><div class="content"><a class="title" href="/web/post/16106.html" title="填坑录">填坑录</a><time datetime="2022-11-26T16:31:04.787Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/web/post/11314.html" title="uniapp开发,遇坑填坑 😘"><img data-lazy-src="/web/img/tab5.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="uniapp开发,遇坑填坑 😘"/></a><div class="content"><a class="title" href="/web/post/11314.html" title="uniapp开发,遇坑填坑 😘">uniapp开发,遇坑填坑 😘</a><time datetime="2022-11-26T16:31:04.746Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/web/post/16107.html" title="Butterfly启动说明书"><img data-lazy-src="/web/img/tab6.png" onerror="this.onerror=null;this.src='/web/img/404.jpg'" alt="Butterfly启动说明书"/></a><div class="content"><a class="title" href="/web/post/16107.html" title="Butterfly启动说明书">Butterfly启动说明书</a><time datetime="2022-11-26T16:31:04.729Z" title="发表于 2022-11-27 00:31:04">2022-11-27</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/web/img/tab99.png')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2022 By ZhuoRu</div><div class="footer_custom_text">I wish you to become your own sun, no need to rely on who's light.<p><a target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a>&nbsp;<a target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a>&nbsp;<a target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a> &nbsp;<a target="_blank" href="https://vercel.com/ "><img src="https://img.shields.io/badge/Hosted-Vervel-brightgreen?style=flat&logo=Vercel" title="本站采用双线部署，默认线路托管于Vercel"></a>&nbsp;<a target="_blank" href="https://vercel.com/ "><img src="https://img.shields.io/badge/Hosted-Coding-0cedbe?style=flat&logo=Codio" title="本站采用双线部署，联通线路托管于Coding"></a>&nbsp;<a target="_blank" href="https://github.com/"><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&logo=GitHub" title="本站项目由Gtihub托管"></a>&nbsp;<a target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&logo=Claris" title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"></a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><a class="icon-V hidden" onclick="switchNightMode()" title="浅色和深色模式转换"><svg width="25" height="25" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/web/js/utils.js"></script><script src="/web/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/web/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>(()=>{
  const $countDom = document.getElementById('twikoo-count')
  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: 'https://wechat-delta.vercel.app/',
      region: 'ap-guangzhou'
    }, null))
  }

  const getCount = () => {
    twikoo.getCommentsCount({
      envId: 'https://wechat-delta.vercel.app/',
      region: 'ap-guangzhou',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      $countDom.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const loadTwikoo = (bool = false) => {
    if (typeof twikoo === 'object') {
      init()
      bool && $countDom && setTimeout(getCount,0)
    } else {
      getScript('https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js').then(()=> {
        init()
        bool && $countDom && setTimeout(getCount,0)
      })
    }
  }

  if ('Twikoo' === 'Twikoo' || !true) {
    if (true) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo(true)
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><canvas id="universe"></canvas><div class="aplayer no-destroy" data-id="7592292364" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true" data-loop="all" data-lrctype="0"> </div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer src="./js/universe.js"></script><script defer src="./js/sun_moon.js"></script><script defer src="https://fastly.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer data-pjax src="/js/wow_init.js"></script><script defer src="https://fastly.jsdelivr.net/npm/hexo-theme-volantis@latest/source/js/issues.min.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_swiper_injector_config(){
    var parent_div_git = document.getElementById('recent-posts');
    var item_html = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;post/1026.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="/img/tab99.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-27</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/1026.html&quot;);" href="javascript:void(0);" alt="">Vue3学习总结</a><div class="blog-slider__text">前端内卷的开始,Vue3开发上手总结</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;post/1026.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;post/1038.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="/img/tab5.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-27</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/1038.html&quot;);" href="javascript:void(0);" alt="">css学习总结</a><div class="blog-slider__text">课程目标:1. 学会使用CSS选择器2. 熟记CSS样式和外观属性3. 熟练掌握CSS各种选择器4. 熟练掌握CSS各种选择器5. 熟练掌握CSS三种显示模式6. 熟练掌握CSS背景属性7. 熟练掌握CSS三大特性8. 熟练掌握CSS盒子模型9. 熟练掌握CSS浮动10.熟练掌握CSS定位11.熟练掌握CSS高级技巧强化CSS</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;post/1038.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;post/16107.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="/img/tab6.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-27</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/16107.html&quot;);" href="javascript:void(0);" alt="">Butterfly启动说明书</a><div class="blog-slider__text">启动说明书</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;post/16107.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;post/2020715.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src="/img/tab2.png" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-27</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/2020715.html&quot;);" href="javascript:void(0);" alt="">html学习总结</a><div class="blog-slider__text">学习目标:了解常用浏览器;掌握WEB标准;理解标签语义化;掌握常用的排版标签;掌握常用的文本格式化图像链接等标签;掌握三种列表标签;掌握表格标签;掌握表格标签;掌握表单标签</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;post/2020715.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载butterfly_swiper')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'undefined'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_swiper_injector_config();
  }
  else if (epage === cpage){
    butterfly_swiper_injector_config();
  }
  </script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script><script defer data-pjax src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper_init.js"></script><script async src="//at.alicdn.com/t/font_2032782_8d5kxvn09md.js"></script><!-- hexo injector body_end end --></body></html>